<?php
include("inc/global.inc");
header("Content-type:text/html; charset=utf-8");
if($_POST[code]){
   if($_POST[code]==$_SESSION[chkCode]){
      if($_POST[userid]&&$_POST[psw]){
         $rs=mysql_query("select id,m_psw,m_user,m_jifen2,m_logintime from member where m_user='$_POST[userid]'");
		 $row=mysql_fetch_array($rs);
		    if($row[id]){
			       if($row[m_psw]==substr(md5($_POST[psw]),7,19)){
				    
					  if(date("Y-m-d",strtotime($row[m_logintime]))!=date("Y-m-d")){
					   $m_jifen2=$row[m_jifen2]+1;
				      }else{
					   $m_jifen2=$row[m_jifen2];
					  }
                      mysql_query("update member set m_logintime='".date("Y-m-d H:i:s")."',m_jifen2='$m_jifen2' where id='$row[id]'");
                      
                      setcookie("user_id",$row["id"]);
				      setcookie("user_name",$row["m_user"]);
					 
				     echo "<script>location.href='/member/'</script>";
				    }else{
					
					echo "<script>alert('密码错误');location='javascript:history.go(-1)';</script>";
					}
		      }else{
			  
			   echo "<script>alert('您的账号错误');location='javascript:history.go(-1)';</script>";
			  }
	  }else{
	       echo "<script>alert('用户名和密码不能为空');location='javascript:history.go(-1)';</script>";
	  }
   }else{
     echo "<script>alert('验证码错误');location='javascript:history.go(-1)';</script>";
   }
}
?>
